package com.example.d_thymeleaf_validator.entity;

import com.example.d_thymeleaf_validator.validator.Area;
import com.example.d_thymeleaf_validator.validator.group.Old;
import com.example.d_thymeleaf_validator.validator.group.Young;
import com.example.enums.AreaEnum;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.*;

/**
 * @author zk
 * @date 2019-10-22 14:12
 */
public class User {
    @NotBlank(groups = {Old.class, Young.class})
    private String name;
    @NotBlank(groups = {Old.class, Young.class})
    @Length(min = 8, max = 16, groups = {Old.class, Young.class})
    private String password;
    @NotBlank(groups = {Old.class, Young.class})
    @Email(groups = {Old.class, Young.class})
    private String email;
    @NotBlank(groups = {Old.class, Young.class})
    private String mobile;
    @DecimalMin(value = "55", message = "{user.old.message}", groups = Old.class)
    @DecimalMax(value = "55", message = "{user.young.message}", groups = Young.class)
    private String age;

    @Area(area = AreaEnum.GAO_XIN, groups = {Old.class, Young.class})
    private AreaEnum area;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getMobile() {
        return mobile;
    }

    public void setMobile(String mobile) {
        this.mobile = mobile;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public AreaEnum getArea() {
        return area;
    }

    public void setArea(AreaEnum area) {
        this.area = area;
    }
}
